{extend name="pub/base" /}
{block name="title"}
<title>漫画管理</title>
{/block}

{block name="body"}
<section class="Hui-admin-article">
    <nav class="breadcrumb" style="background-color:#fff;padding: 0 24px"><i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        漫画管理
        <span class="c-gray en">&gt;</span>
        漫画列表
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
           href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <article class="Hui-admin-content clearfix">
        <div class="panel">
            <div class="panel-body">
                <div class="text-c">
                    <input type="text" placeholder=" 漫画名称" style="width:250px" id="searchParam" class="input-text">
                    <button type="submit" class="btn btn-success" onclick="search()"><i
                            class="Hui-iconfont">&#xe665;</i> 查询
                    </button>
                </div>
                <script>
                    function search() {
                        var param = $('#searchParam').val();
                        location.href = "search?book_name=" + param + "&status=0";
                    }
                </script>
            </div>
        </div>

        <div class="panel mt-20">
            <div class="panel-body">
                <div class="clearfix">
							<span class="f-l">
                                <a href="javascript:;" onclick="delAll()" class="btn btn-danger radius"><i
                                        class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
                                <a class="btn btn-primary radius" onclick="editCreate('漫画新增','{:url(\'create\')}')"><i
                                        class="Hui-iconfont">&#xe600;</i> 添加漫画</a>
                                <a class="btn btn-success radius" onclick="editCreate('付费批量设置','{:url(\'payment\')}')">付费批量设置</a>
							</span>
                    <span class="f-r">共有数据：<strong>{$count}</strong> 条</span>
                </div>
                <div class="mt-20 clearfix">
                    <table class="table table-border table-bordered table-bg table-hover table-sort">
                        <thead>
                        <tr class="text-c">
                            <th><input id="cbx" type="checkbox" value=""></th>
                            <th>ID</th>
                            <th>漫画名</th>
                            <th>封面</th>
                            <th>章节数</th>
                            <th>分类</th>
                            <th>地区</th>
                            <th>起始付费章节</th>
                            <th>章节价格</th>
                            <th>是否完结</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="books" id="vo"}
                        <tr class="text-c">
                            <td><input data-val="{$vo.id}" class="cbx" type="checkbox" value=""></td>
                            <td>{$vo.id}</td>
                            <td>{$vo.book_name}</td>
                            <td>
                                {if empty($vo.cover_url)}
                                <img width="45px;" height="auto" class="picture-thumb"
                                     src="{$img_site}/static/upload/book/{$vo.id}/cover.jpg">
                                {else /}
                                <img width="45px;" height="auto" class="picture-thumb" src="{$vo.cover_url}">
                                {/if}
                            </td>
                            <td>
                                {$vo.chapter_count}
                            </td>
                            <td>{$vo.tags}</td>
                            <td>{$vo.area.area_name}</td>
                            <td>{$vo.start_pay}</td>
                            <td>{$vo.money}</td>
                            <td>{$vo.end?"完结":"连载中"}</td>
                            <td class="f-14 td-manage">
                                <a onclick="editCreate('章节管理','{:url(\'chapters/index\',[\'book_id\' => $vo.id])}')"
                                   class="btn radius btn-success size-S">章节管理</a>
                                <a style="text-decoration:none" class="ml-5"
                                   onclick="editCreate('漫画编辑','edit?id={$vo.id}')">
                                    <i class="Hui-iconfont">&#xe6df;</i>
                                </a>
                                <a style="text-decoration:none" onClick="member_start('{$vo.id}')"
                                   href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>
                                <a style="text-decoration:none" class="ml-5" onclick="del(this,{$vo.id})"
                                   href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                    {$books|raw}
                </div>
            </div>
        </div>
    </article>
</section>
<script>
    $('#cbx').click(function () {
        var cbxs = $('.cbx');
        var flag = $('#cbx').prop("checked");
        $.each(cbxs, function (index, value) {
            $(value).prop("checked", flag);
        })
    })

    function delAll() {
        var cbxs = $('.cbx:checked');
        var arr = [];
        $.each(cbxs, function (index, value) {
            arr.push($(value).attr('data-val'));
        })
        if (arr.length <= 0) {
            layer.msg('请选择要删除的漫画', {icon: 2});
        } else {
            $.ajax({
                type:'post',
                url: '{:url("books/deleteAll")}',
                data: {ids: arr},
                success(res){
                    layer.msg('批量删除成功', {icon: 1, time: 1000}, function () {
                        location.reload();
                    });
                }
            })
        }
    }
</script>
{/block}